const express = require('express')
const app = new express()
const mongoose = require('mongoose')
const users = require('./route/user')
const product = require('./route/product')
const admin = require('./route/admin')


bodyParser = require('body-parser')
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: false}))




app.use('/users', users) // 将路由注册到/users的路径下
app.use('/product',product)
app.use('/admin',admin)




var port = process.env.PORT || 3000

app.listen(port)
console.log('正在监听端口: ' + port)

var url = "mongodb://localhost:27017/vtmapp"
mongoose.connect(url, (err) => {
    if (err) {
        console.log(err)
    } else {
        console.log('已连接数据库')
    }
})